package com.ruoyi.web.controller.medical;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.medical.domain.Alarmlocal;
import com.ruoyi.medical.service.IAlarmlocalService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * alarmlocalController
 *
 * @author ruoyi
 * @date 2025-10-30
 */
@RestController
@RequestMapping("/medical/alarmlocal")
public class AlarmlocalController extends BaseController
{
    @Autowired
    private IAlarmlocalService alarmlocalService;

    /**
     * 查询alarmlocal列表
     */
    @PreAuthorize("@ss.hasPermi('medical:alarmlocal:list')")
    @GetMapping("/list")
    public TableDataInfo list(Alarmlocal alarmlocal)
    {
        startPage();
        List<Alarmlocal> list = alarmlocalService.selectAlarmlocalList(alarmlocal);
        return getDataTable(list);
    }

    /**
     * 导出alarmlocal列表
     */
    @PreAuthorize("@ss.hasPermi('medical:alarmlocal:export')")
    @Log(title = "alarmlocal", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Alarmlocal alarmlocal)
    {
        List<Alarmlocal> list = alarmlocalService.selectAlarmlocalList(alarmlocal);
        ExcelUtil<Alarmlocal> util = new ExcelUtil<Alarmlocal>(Alarmlocal.class);
        util.exportExcel(response, list, "alarmlocal数据");
    }

    /**
     * 获取alarmlocal详细信息
     */
    @PreAuthorize("@ss.hasPermi('medical:alarmlocal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(alarmlocalService.selectAlarmlocalById(id));
    }

    /**
     * 新增alarmlocal
     */
    @PreAuthorize("@ss.hasPermi('medical:alarmlocal:add')")
    @Log(title = "alarmlocal", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Alarmlocal alarmlocal)
    {
        return toAjax(alarmlocalService.insertAlarmlocal(alarmlocal));
    }

    /**
     * 修改alarmlocal
     */
    @PreAuthorize("@ss.hasPermi('medical:alarmlocal:edit')")
    @Log(title = "alarmlocal", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Alarmlocal alarmlocal)
    {
        return toAjax(alarmlocalService.updateAlarmlocal(alarmlocal));
    }

    /**
     * 删除alarmlocal
     */
    @PreAuthorize("@ss.hasPermi('medical:alarmlocal:remove')")
    @Log(title = "alarmlocal", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(alarmlocalService.deleteAlarmlocalByIds(ids));
    }
}
